<?php
    session_start();
    if($_SESSION['uid']==""||$_SESSION['level']!=2){
        header("Location: ../exit.php");
        exit();
    }

    include('/tool/submitValidate.php');
    include('/tool/pdo.php');
    include('/class/class-dormitory-management.class.php');
    include('/bll/ClassDormitoryManagementBLL.php');

    $action = isset($_POST['action'])?$_POST['action']:3;
    $data = isset($_POST['data'])?$_POST['data']:null;

    $result=array();
    switch((int)$action){
        case 1:break;
        case 3:
            $json='[{"grade":"2014","major":"1","class":"1"}]';
            $jsonObj=json_decode($json);
            $removeList=json_decode($data);
            if(!$removeList==null){
                $ClassDormitoryManagementBLL=new ClassDormitoryManagementBLL();
                $result=$ClassDormitoryManagementBLL->removeClassDormitoryAllocate('1234561',$jsonObj);
            }
            break;
        default:break;
    }

    echo json_encode($result,JSON_UNESCAPED_UNICODE);
?>